//数据请求  头部及目录
$.ajax({
	type: "post",
	url: Urls + "/api/Special/GetSpecialDetail",
	data: JSON.stringify({
		"SpecialId": Id,
		"MemberAccount": ""
	}),
	success: function(res) {
		var Data = res.Data;
		var ClassList = Data.ClassList;
		var PhotoUrl = Data.SpecialInfo.PhotoUrl;
		var Title = Data.SpecialInfo.Title;
		var SubTitle = Data.SpecialInfo.SubTitle;
		var Author = Data.SpecialInfo.Author;
		var Fee = Data.SpecialInfo.Fee;
		var SpecialCount = Data.SpecialInfo.SpecialCount;
		var Description = Data.SpecialInfo.Description;
		var SpecialInfo = Data.SpecialInfo;
		var PhotoUrl = SpecialInfo.PhotoUrl;
		$('.details .contents img').attr('src', PhotoUrl)
		$(".hangder_img").append("<img src=" + PhotoUrl + ">");
		$('.hangder_wenzi p:nth-child(1)').text(Title);
		$('.hangder_wenzi p:nth-child(2)').text(SubTitle);
		$('.hangder_wenzi .author').text(Author);
		$('.hangder_wenzi .fee i').text(Fee);
		$('.hangder_wenzi .ke_num').text(SpecialCount);
		document.querySelector(".con").innerHTML = Description;
		for(var i = 0; i < ClassList.length; i++) {
			var PhotoUrl = ClassList[i].PhotoUrl;
			var Title = ClassList[i].Title;
			var SubTitle = ClassList[i].SubTitle;
			var Author = ClassList[i].Author;
			var content_li = "<li><div><img src=" + PhotoUrl + " /></div><div><p>" + Title + "</p><p>" + SubTitle + "</p><p>" + Author + "</p></div></li>";
			$('.content ul').append(content_li);
		}
	}
})

//评论
$.ajax({
	type: "post",
	url: Urls + "/api/Cms/GetComment",
	data: JSON.stringify({
		"ObjectId": Id,
		"ParentId": "0",
		"Type": "OBJECT",
		"PageIndex": 1,
		"PageSize": 5,
		"MemberAccount": "",
		"CommentType": "SPECIAL"
	}),
	success: function(res) {
		console.log(res);
		var Data = res.Data;
		$('.comment_p span').text(res.TotalCount);
		for(var i = 0; i < Data.length; i++) {
			var Class_comment = '<li>' +
				'<div>' +
				'<div><img src="' + Data[i].Icon + '" /></div>' +
				'<div>' +
				'<p>' + Data[i].Name + '</p>' +
				'<p>' + Data[i].CommentDate + '</p>' +
				'</div>' +
				'<div>' +
				'<img src="img/2.png" />' +
				'<p>' + Data[i].PraiseTime + '</p>' +
				'</div>' +
				'</div>' +
				'<div>' +
				'<p>' + Data[i].Content + '</p>' +
				'</div>' +
				'</li>';
			$('.comments ul').append(Class_comment)
		}
	}
});

//轮播图数据请求
$.ajax({
	type: "post",
	url: Urls + "/api/Special/GetSpecialList",
	data: JSON.stringify({
		"PageIndex": 1,
		"PageSize": 2,
		"MemberAccount": "",
		"SpecialId": Id
	}),
	success: function(res) {
		var SpecialList = res.Data.SpecialList;
		for(var i = 0; i < SpecialList.length; i++) {

			var sweime = '<div class="swiper-slide sweione">' +
				'<img src="' + SpecialList[i].PhotoUrl + '" />' +
				'<p>' + SpecialList[i].Title + '</p>' +
				'</div>';
			$('.swiper-wrapper').append(sweime);
		}
		//轮播图
		var mySwiper = new Swiper('.swiper-container', {
			slidesPerView: 2, //'auto'
			observer: true, //修改swiper自己或子元素时，自动初始化swiper
			observeParents: false, //修改swiper的父元素时，自动初始化swiper
			onTransitionEnd: function(swiper) {
				if(swiper.progress == 1) {
					swiper.activeIndex = swiper.slides.length - 1
				}
			}
		})
	}
});